<!DOCTYPE html>
<html>

<head>
    <title>新能源大数据精细化分析与创新服务平台</title>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="custom/images/favicon.ico?v=2" />
    <style>
        html,
        body {
            padding: 0px;
            margin: 0px;
        }
    </style>
   <script src='../libs/core/ht.js'></script>
   <script src='../libs/core/ht-ui.js'></script>

   <script src='../libs/plugin/ht-edgetype.js'></script>
   <script src="../libs/plugin/ht-obj.js"></script>
   <script src='../libs/plugin/ht-form.js'></script>
   <script src='../libs/plugin/ht-vector.js'></script>
   <script src='../libs/plugin/ht-animation.js'></script>

   <script src='../../configs/htconfig.js'></script>

   <!-- <script src="../libs/china.js"></script> -->
   <script src="../libs/echarts.min.js"></script>
   <script src='../libs/echarts.js'></script>
   <script src='../libs/jquery-3.4.1.min.js'></script>
   <script src='../libs/echarts.js'></script>
   <script src='../libs/buckle.js'></script>
   <script src='../libs/knU3sXefAa5Q.js'></script>
<script src="../../configs/urlConfig.js"></script>
    <script>
        var dataModel = new ht.DataModel();
     //    var url="http://172.16.11.150/epplatform/v1/";
     var url=attributeConfigs.url+'/epplatform/v1/';


        var attributeConfig = {
            url1:url+"alertMap",
            url2:url+"consumption/overview?areaCode=04",
            url3:url+"consumption/substationMap?areaCode=04",
        };

        function init() {
            var gd2 = new ht.graph.GraphView(dataModel);
            gd2.addToDOM();
            gd2.deserialize('displays/冀北/消纳/廊坊/jibei-langfang.json', function (json, dm, g2d, datas) {

//    电量统计
                var dian11=dm.getDataByTag('xin-neng-yuan');
                var dian12=dm.getDataByTag('lei-ji-fa');
                var dian13=dm.getDataByTag('lei-ji-zeng-fa');
                var dian14=dm.getDataByTag('feng');
                var dian15=dm.getDataByTag('guang');
                var dian16=dm.getDataByTag('qi-feng');
                var dian17=dm.getDataByTag('qi-guang');

                var electricity=updateDataModel(attributeConfig.url2);

                var installedCapacity;
                var  electricity2;
                var  increasedElectricity;
                var  windUseOfHours;
                var  lightUseOfHours;
                var  discardWindElectricity;
                var  discardLightElectricity;

                if (electricity.installedCapacity==null || typeof(electricity.installedCapacity)=="undefine"){
                    installedCapacity='--';
                }else {
                    installedCapacity=electricity.installedCapacity;
                }

                if (electricity.electricity==null || typeof(electricity.electricity)== "undefine"){
                    electricity2='--';
                }else {
                    electricity2=electricity.electricity;
                }

                if (electricity.increasedElectricity==null || typeof(electricity.increasedElectricity)== "undefine"){
                    increasedElectricity='--';
                }else {
                    increasedElectricity=electricity.increasedElectricity;
                }

                if (electricity.windUseOfHours==null || typeof(electricity.windUseOfHours)== "undefine"){
                    windUseOfHours='--';
                }else {
                    windUseOfHours=electricity.windUseOfHours;
                }

                if (electricity.lightUseOfHours==null || typeof(electricity.lightUseOfHours)== "undefine"){
                    lightUseOfHours='--';
                }else {
                    lightUseOfHours=electricity.lightUseOfHours;
                }

                if (electricity.discardWindElectricity==null || typeof(electricity.discardWindElectricity)=="undefine"){
                    discardWindElectricity='--';
                }else {
                    discardWindElectricity=electricity.discardWindElectricity;
                }

                if (electricity.discardLightElectricity ==null || typeof(electricity.discardLightElectricity)=="undefine"){
                    discardLightElectricity='--';
                }else {
                    discardLightElectricity=electricity.discardLightElectricity;
                }

                dian11.s('text',installedCapacity+'MW');
                dian12.s('text',electricity2+'亿kWh');
                dian13.s('text',increasedElectricity+'亿kWh');
                dian14.s('text',windUseOfHours+'h');
                dian15.s('text',lightUseOfHours+'h');
                dian16.s('text',discardWindElectricity+'亿kWh');
                dian17.s('text',discardLightElectricity+'亿kWh');


//地图上的图标
                var data2=updateDataModel(attributeConfig.url3);
                createNodes(dm, data2);

//风电

                var dian1=dm.getDataByTag('dian1');
                var dian2=dm.getDataByTag('dian2');

                var val1=updateDataModel(url+"consumption/windPowerHours?areaCode=04");
                var months1=[];
                var lastYearPowerHours1=[];
                var thisYearPowerHours1=[];
                var yearOnYear1=[];
                months1=val1.months;
                lastYearPowerHours1=val1.lastYearPowerHours;
                thisYearPowerHours1=val1.thisYearPowerHours;
                yearOnYear1=val1.yearOnYear;

                var val2=updateDataModel(url+"consumption/abandonWindElectricity?areaCode=04");
                var months2=[];
                var lastYearPowerHours2=[];
                var thisYearPowerHours2=[];
                var yearOnYear2=[];
                months2=val2.months;
                lastYearPowerHours2=val2.lastYearAbandonWindElectricity;
                thisYearPowerHours2=val2.thisYearAbandonWindElectricity;
                yearOnYear2=val2.yearOnYear;

                dian1.a('xValue',months1);
                dian1.a('barData1',thisYearPowerHours1);
                dian1.a('barData2',lastYearPowerHours1);
                dian1.a('lineData',yearOnYear1);

                dian2.a('xValue',months2);
                dian2.a('barData1',thisYearPowerHours2);
                dian2.a('barData2',lastYearPowerHours2);
                dian2.a('lineData',yearOnYear2);

            });
        }


        // 获取后台数据
        var values=new Array();
        function updateDataModel(geturl){
            $.ajax({
                type : "GET",
                async : false, //同步请求
                url : geturl,
                contentType: "application/json; charset=utf-8",
                success:function(data){
                    if(data.code==0){
                        values = data.data;
                    }
                },
                error: function() {
                    alert("失败，请稍后再试！");
                }
            });
            return  values;
        }


        function createNodes(dm, datas) {
            for (var i = 0; i < datas.length; i++) {
                var node = new ht.Node();
                node.setLayer('1');

                if(datas[i].type == 2){
                    node.setImage('assets/冀北/biandianzhan.png');
                }else if (datas[i].type == 1){
                    node.setImage('assets/冀北/biandianzhan2.png');
                }
                var temp = datas[i];
                if (temp.name) {
                    node.setDisplayName(name);
                }
                if (temp.position) {
                    node.setRect(temp.position.x, temp.position.y, 36, 36);
                    node.setName(temp.name);
                    node.s('label.color', '#008F8A');//名称颜色
                    node.s('label.font', '14px Microsoft YaHei');//名称字体
                    node.s('label.offset.y', 5);//文字位置y轴偏移量
                    node.s('label.background', 'rgba(255,255,255,1)');//文字背景颜色
                }
                if(temp.id){
                    node.setId(1000+temp.id);
                }else{
                    node.setId(1000 + i);
                }
                node.s('2d.movable',false);
                dm.add(node);
            }
        }

    </script>
</head>
<body onload='setInterval(init(), 30000)' >
</body>

</html>
